import base_control from "@/lib/core/base_control.js"
import vNode from "@/lib/core/structs/render_vNode.js"
function button(args = undefined, context = undefined, compile_source_file = undefined) {
    this.context = context
    this.constructor_template = {
        functional: true,
        name: "t-button",
        data() {
            return {
                vtext: "ddddd"
            };
        },
        methods: {
            clickHandle: (event) => {
                this.Debug([`[button.clickHandle] `, event])
                this._instance.$emit('click', event)
            }
        },
        props: {
            renderOps: { Object, default: () => { } },
            text: { String, default: () => "Btn" },
            disabled: { Boolean, default: () => false },
            ghost: { Boolean, default: () => false },
            htmlType: { String, default: () => "button" },
            icon: { String, default: () => "noset" },
            loading: { Object, default: () => false },
            size: { String, default: () => "default" },
            type: { String, default: () => "default" },
            block: { Boolean, default: () => false },
            shape: { String, default: () => "noset" }
        }
    };
    //this.renderOps= args
    this.render_ops = (args == undefined | args == null) ? {
        el:"#app",
        //parentEl: "app",
        //mountType: "append",
        attrs: { type: "primary" },
        propsData: {
            text: "示范",
            disabled: false,
            ghost: false,
            htmlType: "button",
            icon: "",
            loading: false,
            size: undefined,
            type: undefined,
            block: false
        }
    } : args;

    this.v_node = new vNode('span')
    this.v_node.appendChild('a-button', (() => {
        let cfg = {
            on: {
                click: (event)=>{
                    let self= this._instance
                    self.$emit('click',event)
                }
            },
            attrs: {
                type: "primary"
            },
            propsData: {
                text: "self.text",
                disabled: "self.disabled",
                ghost: "self.ghost",
                htmlType: "self.htmlType",
                icon: "self.icon",
                loading: "self.loading",
                size: "self.size",
                type: "self.type",
                block: "self.block"
            }
        }
        return cfg
    })()).appendChild('span', { slot: "default" }).setValue("self.vtext")
    return this.build({ constructor: this.constructor_template, render: this.render_ops, vnode: this.v_node, compile_file: compile_source_file })
}

button.prototype = new base_control();
button.prototype.constructor = button;
export default button
